package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NuringLeverMapper;
import com.zzyl.service.NuringLeverServer;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class NuringLeverServerImpl implements NuringLeverServer {


    @Resource
    NuringLeverMapper nuringLeverMapper;
    @Override
    public List<NursingLevelVo> selectAllNursingLevelServer() {

        List<NursingLevel> list = nuringLeverMapper.selectAllNursingMapper();
        List<NursingLevelVo> list1 = new ArrayList<>();

        list.forEach(nursingLevel -> list1.add(BeanUtil.toBean(nursingLevel, NursingLevelVo.class)));
        return list1;


     /*   list.forEach(nursingLevel -> BeanUtil.toBean(nursingLevel, NursingLevelVo.class))*/

      /*  NursingLevelVo nursingLevelVo = BeanUtil.toBean(list<NursingLevel>,);*/




    }

    @Override
    public void nursingLevelServer(NursingLevelDto nursingLevelDto) {

        NursingLevel nursingLevel = BeanUtil.toBean(nursingLevelDto, NursingLevel.class);

        nuringLeverMapper.nursingLevelMapper(nursingLevel);

    }




    @Override
    public void EnableDisableServer(Integer id, Integer status) {


           nuringLeverMapper.enableDisableMapper(id,status);


    }

    @Override
    public void deleteServer(Integer id) {
        nuringLeverMapper.deleteNursingLevelMapper(id);
    }
}
